import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '企业编码',
    align: "center",
    sorter: true,
    dataIndex: 'companyCode'
  },
  {
    title: '企业名称',
    align: "center",
    sorter: true,
    dataIndex: 'name'
  },
  {
    title: '企业简介',
    align: "center",
    dataIndex: 'synopsis'
  },
  {
    title: '所在地区',
    align: "center",
    dataIndex: 'area',
  },
  {
    title: '详细地址',
    align: "center",
    dataIndex: 'detailedAddress'
  },
  {
    title: '经度',
    align: "center",
    dataIndex: 'longitude'
  },
  {
    title: '纬度',
    align: "center",
    dataIndex: 'latitude'
  },
  {
    title: '邮政编号',
    align: "center",
    dataIndex: 'zipCode'
  },
  {
    title: '法人姓名',
    align: "center",
    dataIndex: 'legalPersonName'
  },
  {
    title: '企业电话',
    align: "center",
    dataIndex: 'tel'
  },
  {
    title: '企业LOGO',
    align: "center",
    dataIndex: 'logo',
    customRender: render.renderImage,
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "企业编码",
    field: 'companyCode',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "企业名称",
    field: 'name',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "法人姓名",
    field: 'legalPersonName',
    component: 'Input',
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '企业编码',
    field: 'companyCode',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入企业编码!'},
             ];
    },
  },
  {
    label: '企业名称',
    field: 'name',
    component: 'Input',
  },
  {
    label: '企业简介',
    field: 'synopsis',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入企业简介!'},
             ];
    },
  },
  {
    label: '所在地区',
    field: 'area',
    component: 'JAreaLinkage',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入所在地区!'},
             ];
    },
  },
  {
    label: '详细地址',
    field: 'detailedAddress',
    component: 'InputTextArea',
  },
  {
    label: '经度',
    field: 'longitude',
    component: 'InputTextArea',
  },
  {
    label: '纬度',
    field: 'latitude',
    component: 'Input',
  },
  {
    label: '邮政编号',
    field: 'zipCode',
    component: 'Input',
  },
  {
    label: '法人姓名',
    field: 'legalPersonName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入法人姓名!'},
             ];
    },
  },
  {
    label: '企业电话',
    field: 'tel',
    component: 'Input',
  },
  {
    label: '企业LOGO',
    field: 'logo',
    component: 'JImageUpload',
    componentProps:{
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  companyCode: {title: '企业编码',order: 0,view: 'text', type: 'string',},
  name: {title: '企业名称',order: 1,view: 'text', type: 'string',},
  synopsis: {title: '企业简介',order: 2,view: 'textarea', type: 'string',},
  area: {title: '所在地区',order: 3,view: 'pca', type: 'string',},
  detailedAddress: {title: '详细地址',order: 4,view: 'textarea', type: 'string',},
  longitude: {title: '经度',order: 4,view: 'text', type: 'string',},
  latitude: {title: '纬度',order: 4,view: 'text', type: 'string',},
  zipCode: {title: '邮政编号',order: 5,view: 'text', type: 'string',},
  legalPersonName: {title: '法人姓名',order: 6,view: 'text', type: 'string',},
  tel: {title: '企业电话',order: 7,view: 'text', type: 'string',},
  logo: {title: '企业LOGO',order: 8,view: 'image', type: 'string',},
};
